﻿using JiveMessenger.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace JiveMessenger.CustomControls
{
    /// <summary>
    /// Interaction logic for MessageDownloadControl.xaml
    /// </summary>
    public partial class MessageDownloadControl : UserControl
    {
                public static readonly DependencyProperty DownloadMessagesCommandProperty =
            DependencyProperty.Register(
            "DownloadMessagesCommand",
            typeof(ICommand),
            typeof(MessageDownloadControl));

                public ICommand DownloadMessagesCommand
        {
            get { return (ICommand)GetValue(DownloadMessagesCommandProperty); }
            set { SetValue(DownloadMessagesCommandProperty, value); }
        }

                public static DependencyProperty DownloadMessagesCommandParameterProperty =
    DependencyProperty.Register("DownloadMessagesCommandParameter", typeof(object), typeof(MessageDownloadControl));
                public object DownloadMessagesCommandParameter
                {
                    get { return GetValue(DownloadMessagesCommandParameterProperty); }
                    set { SetValue(DownloadMessagesCommandParameterProperty, value); }
                }



                public int AgeLimit
                {
                    get { return (int)GetValue(AgeLimitProperty); }
                    set { SetValue(AgeLimitProperty, value); }
                }

                // Using a DependencyProperty as the backing store for AgeLimit.  This enables animation, styling, binding, etc...
                public static readonly DependencyProperty AgeLimitProperty =
                    DependencyProperty.Register("AgeLimit", typeof(int), typeof(MessageDownloadControl), new PropertyMetadata(24));



        public MessageDownloadControl()
        {
            InitializeComponent();
            this.DataContext = this;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.DownloadMessagesCommandParameter = new MessageDownload(Convert.ToInt32(this.MessageCountSlider.Value), Convert.ToInt32(this.MessageAgeSlider.Value));
          this.DownloadMessagesCommand.Execute(this.DownloadMessagesCommandParameter);
        }
    }
}
